﻿using IntelligentAgriculture.Contracts.Interface.EarTagService;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.EarTageManageCommandJamdler
{
	/// <summary>
	/// 显示未使用的耳标
	/// </summary>
	public class ShowStateEartagCommandHandler : IRequestHandler<ShowStateEartagCommand, Results<IQueryable<Eartag>>>
	{
		private readonly IEarTageService _iearTageService;

		public ShowStateEartagCommandHandler(IEarTageService iearTageService)
		{
			_iearTageService = iearTageService;
		}
		/// <summary>
		/// 显示未使用的耳标
		/// </summary>
		/// <param name="request"></param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>
		/// <exception cref="NotImplementedException"></exception>
		public async Task<Results<IQueryable<Eartag>>> Handle(ShowStateEartagCommand request, CancellationToken cancellationToken)
		{
			var result =  await _iearTageService.ShowStateEartag();
			return Results<IQueryable<Eartag>>.DataResult(result);
		}
	}
}
